// -*- C++ -*-

//========================================================================
/**
 * Author   : cuisw <shaovie@gmail.com>
 * Date     : 2009-06-10 23:13
 */
//========================================================================

#ifndef NDK_REACTOR_TOKEN_H_
#define NDK_REACTOR_TOKEN_H_

#include "ndk/token.h"
#include "ndk/reactor_impl.h"

namespace ndk
{
  // Forward declarations
  //

  /**
   * @class reactor_token
   * 
   * @brief 
   */
  class reactor_token : public token
  {
  public:
    reactor_token(reactor_impl *r_impl,
                  int s_queue = token::FIFO)
    : token (s_queue),
    reactor_(r_impl)
    { }

    virtual ~reactor_token()
    { }

    inline reactor_impl *reactor()
    {
      return this->reactor_;
    }

    inline void reactor(reactor_impl *r)
    {
      this->reactor_ = r;
    }

    inline virtual void sleep_hook(void)
    {
      if (this->reactor_)
        this->reactor_->notify();
    }
  private:
    reactor_impl *reactor_;
  };
} // namespace ndk

#endif // NDK_REACTOR_TOKEN_H_

